<?php

abstract class Light_View_Helper_Abstract
{    /**
     * @var Light_View
     */
    public $view;

    /**
     * @var string
     */
    protected $_viewScriptName = null;

    public function __construct()
    {

    }

    /**
     * @return Light_View
     */
    public function getView()
    {
        return $this->view;
    }

    /**
     * @param Light_View $view
     * @return Light_View_Helper_Abstract
     */
    public function setView(Light_View $view)
    {
        $this->view = $view;

        return $this;
    }

    /**
     * @return the $_viewScriptName
     */
    public function getViewScriptName()
    {
        return $this->_viewScriptName;
    }

    /**
     * @param string $_viewScriptName
     * * @return Light_View_Helper_Abstract
     */
    public function setViewScriptName($_viewScriptName)
    {
        $this->_viewScriptName = $_viewScriptName;

        return $this;
    }

    public function render()
    {
        return $this->view->render($this->getViewScriptName(), true);
    }

    /**
     * @return string
     */
    public function __toString()
    {
        try {
            $output = $this->render();
        } catch (Exception $e) {
            $output = $e->__toString();
        }

        return $output;
    }
}